package com.cefa.finance.controller;

import com.cefa.finance.model.Contract;
import com.cefa.finance.result.ResultModel;
import com.cefa.finance.service.UserCreditInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("userCreditInfo")
public class UserCreditController {

    private static final Logger logger = LoggerFactory.getLogger(UserCreditController.class);

    @Autowired
    private UserCreditInfoService userCreditInfoService;

    @RequestMapping(path = "listuserCreditInfo", method = RequestMethod.POST)
    @CrossOrigin
    public ResultModel listuserCreditInfo(String searchText, Integer pageNo, Integer pageCount) {
        try {
            return  userCreditInfoService.listuserCreditInfo2(searchText, pageNo, pageCount);
        } catch (Exception e) {
            logger.error(e.getMessage());
            return ResultModel.ERROR(e.getMessage());
        }
    }

    @RequestMapping(path = "listCertainUserCreditInfo", method = RequestMethod.POST)
    @CrossOrigin
    public ResultModel listCertainUserCreditInfo(Contract contract) {
        try {
            return  userCreditInfoService.listCertainUserCreditInfo(contract);
        } catch (Exception e) {
            logger.error(e.getMessage());
            return ResultModel.ERROR(e.getMessage());
        }
    }

}
